package slacker;

/**
 * 懒汉模式
 * @author gaopeng
 * @date 2019/12/7 3:31 下午
 */
public class Emperor {
    private static Emperor emperor = null;

    private Emperor(){}

    public synchronized static Emperor getInstance(){
        if(emperor==null){
            System.out.println("created");
            emperor = new Emperor();
        }
        return emperor;
    }

    public void say(String name){
        System.out.println("我是皇帝Emperor。"+name);
    }
}
